//
//  DeviceModel.m
//  ZQSmartLife
//
//  Created by huanghuan on 15/6/10.
//  Copyright (c) 2015年 huanghuan. All rights reserved.
//

#import "ZQDeviceModel.h"

@implementation ZQDeviceModel
-(id) initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self)
    {
        _name = [dic objectForKey:@"name"];

        _deviceType = [[dic objectForKey:@"deviceType"] intValue];
        _rcType = [dic objectForKey:@"rcType"];
        _ver = [[dic objectForKey:@"deviceVersion"] intValue];
        _addr = [dic objectForKey:@"deviceAddr"];
        _systemId = [dic objectForKey:@"systemId"];
        _visible = [[dic objectForKey:@"visiable"]intValue];
        _order = [[dic objectForKey:@"orders"] intValue];
        self.Id = [[dic objectForKey:@"id"] intValue];
        
        _ver = 1;
    }
    return self;
}

-(NSDictionary *)dictionary
{
        return [NSDictionary dictionaryWithObjectsAndKeys:_name,DEVICE_NAME,
                _icon?_icon:@"",DEVICE_ICON,
                _addr,DEVICE_ADDR,
                _rcType?_rcType:@"",DEVICE_RCTYPE,
                [NSNumber numberWithInt:_roomId],DEVICE_ROOMID,
                [NSNumber numberWithInt:_deviceType],DEVICE_DEVICETYPE,
                _systemId?_systemId:@"",DEVICE_SYSTEMID,
                [NSNumber numberWithInt:_visible],DEVICE_VISIBLE,
                [NSNumber numberWithInt:_ver],DEVICE_VERSION,
                [NSNumber numberWithInt:_order],DEVICE_ORDERS,
                nil];
    
}

-(id) copy
{
    ZQDeviceModel *device = [ZQDeviceModel new];
    
    device.Id = self.Id;
    device.name = [self.name mutableCopy];
    device.deviceType = self.deviceType;
    device.rcType = [self.rcType mutableCopy];
    device.ver = self.ver;
    device.addr = [self.addr mutableCopy];
    device.icon = [self.icon mutableCopy];
    device.roomId = self.roomId;
    device.systemId = [self.systemId mutableCopy];
    device.visible = self.visible;
    device.order = self.order;
    return device;
    
}

-(id) copyWithZone:(id) zone
{
    ZQDeviceModel *device = [ZQDeviceModel new];
    
    device.Id = self.Id;
    device.name = [self.name mutableCopy];
    device.deviceType = self.deviceType;
    device.rcType = [self.rcType mutableCopy];
    device.ver = self.ver;
    device.addr = [self.addr mutableCopy];
    device.icon = [self.icon mutableCopy];
    device.roomId = self.roomId;
    device.systemId = [self.systemId mutableCopy];
    device.visible = self.visible;
    device.order = self.order;
    return device;
    
}



@end
